a = "123456"
b = "99999"

# a = "99999"
# b = "99999"

a_list = [int(c) for c in a]
a_list.reverse()

# b_list = list(b)

b_list = [int(c) for c in b]
b_list.reverse()

adv = 0

if len(a_list) > len(b_list):
    max_list = a_list
    min_list = b_list
else:
    max_list = b_list
    min_list = a_list

def split_num(v):
    a = v // 10
    b = v % 10
    return a, b

adv = 0
c_list = []
i = 0
for i in range(0, len(min_list)):
    c = a_list[i] + b_list[i] + adv
    s, g = split_num(c)
    c_list.append(g)
    adv = s

for j in range(i + 1, len(max_list)):
    c = max_list[j] + adv
    s, g = split_num(c)
    c_list.append(g)
    adv = s

if adv > 0:
    c_list.append(adv)

c_list.reverse()

result = ""
for item in c_list:
    result += str(item)

print(result)
